#define _CRT_SECURE_NO_WARNINGS 1class Solution {
public:
    int minSideJumps(vector<int>& obstacles) {
        int n = obstacles.size();
        vector<vector<int>> dp(n, vector<int>(4, 1e9));
        dp[0][2] = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 1; j < 4; j++)
            {
                if (dp[i][j] == 1e9) continue;
                if (obstacles[i + 1] == j) {
                    for (int k = 1; k < 4; k++)
                        if (k == j) continue;
                        else if (obstacles[i] == k) continue;
                        else dp[i][k] = min(dp[i][k], dp[i][j] + 1), dp[i + 1][k] = dp[i][k];
                }
                else dp[i + 1][j] = dp[i][j];
            }
        }
        return min(dp[n - 1][1], min(dp[n - 1][2], dp[n - 1][3]));
    }
};